package com.pems.controller.system;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
 

@Controller
public class Test {
	@Resource(name="testDao")
	private TestDao testDao;
	
	@RequestMapping(value="/test/test")
	public ModelAndView test(HttpServletRequest request,HttpServletResponse response){
		ModelAndView mav = new ModelAndView();
		mav.setViewName("/test/test");
		return mav;
	}
	
	 @RequestMapping(value="/test/getRealmByParam1",method=RequestMethod.POST,produces="application/json;charset=UTF-8")
	public @ResponseBody List getRealmByParam1(HttpServletRequest request,HttpServletResponse response){
	 
				String postType=request.getParameter("postType");
				String currNodeId=request.getParameter("currNodeId");
				List<HashMap<String, Object>> ls =null;
				HashMap<String, Object> param1 =new HashMap<String, Object>();
				if("1".equals(postType)){//此请求为获取本节点数据
					param1.put("realmId", currNodeId);
					 ls =testDao.getRealmByParam(param1); 
					
				}else if("2".equals(postType)){//获取子节点
					param1.put("parentId", currNodeId);
					ls=testDao.getRealmByParam(param1); 
					 
				}else if("3".equals(postType)){//获取兄弟节点
					param1.put("typeIdBrother", currNodeId);
					ls=testDao.getRealmByParam(param1); 
				}
		 
			return ls;
		}
 
}
